<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" isELIgnored="false" %>
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>展示图书信息</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/style.css" />
	</head>
	<body>
		<div id="wrap">
			<div id="top_content"> 
				<div id="header">
					<div id="rightheader">
						<p>
							2009/11/20
							<br />
						</p>
					</div>
					<div id="topheader">
						<h1 id="title">
							<a href="#">main</a> 
						</h1>
					</div>
					<div id="navigation">
					</div>
				</div>
				<div id="content">
					<p id="whereami">
					</p>
					<h1>
						Welcome!

					</h1>
					<form action="${pageContext.request.contextPath}/book/selectAllByPageMvc.do" method="post">
						名称：<input type="text" name="nameSearch"><br/>
						价格：<input type="text" name="priceSearch"><br/>
						类别：<input type="text" name="typeSearch">
						<input type="submit" value="搜索">
						<a href="${pageContext.request.contextPath}/book/refreshMvc.do">刷新</a>
					</form>
					<form method="post" action="${pageContext.request.contextPath}/book/deletesByIdsMvc.do" onsubmit="return false" id="formDelete">
						<script>
							function selectAll(){
								var totalBox = document.getElementById("totalBox")
								var myBox = document.getElementsByClassName("myBox")
								for(var i = 0;i<myBox.length;i++){
									myBox[i].checked=totalBox.checked
								}
							}
							function checkAll(){
								var totalBox = document.getElementById("totalBox")
								var myBox = document.getElementsByClassName("myBox")
								for(var i = 0;i<myBox.length;i++){
									if(myBox[i].checked==false){
										totalBox.checked = false
										return
									}
								}
								totalBox.checked = true
							}
						</script>
					<table class="table">
						<tr class="table_header">
						    <td>全选<input type="checkbox" id="totalBox" onclick="selectAll()"></td>
							<td>编号</td>
							<td>图书名称</td>
							<td>图书价格</td>
							<td>作者</td>
							<td>入库时间</td>
							<td>类别名称</td>
							<td>操作</td>
						</tr>
						<c:forEach items="${bookList}" var="book">
							<tr>
								<td><input type="checkbox" name="ids" value="${book.bookId}" class="myBox" onclick="checkAll()"></td>
								<td>${book.bookId}</td>
								<td>${book.bookName}</td>
								<td>${book.bookPrice}</td>
								<td>${book.author}</td>
								<td>${book.bookGroundingDate}</td>
								<td>${book.type.typeName}</td>
								<script>
									function deleteCheck(id){
										var boo = confirm("确认删除这条数据吗？")
										if(boo){
											location.href = "${pageContext.request.contextPath}/book/deleteByBookIdMvc.do?bookId="+id
										}
									}
								</script>
								<td><a href="javascript:void(0)" onclick="deleteCheck(${book.bookId})">删除</a>
									<a href="${pageContext.request.contextPath}/book/selectByBookIdMvc.do?bookId=${book.bookId}">修改</a>
								</td>
							</tr>
						</c:forEach>

					</table>
						<script>
							function confirmCheck(){
								var formDelete = document.getElementById("formDelete")
								var boo = confirm("确认删除多个选项？")
								if(boo){
									formDelete.submit()
								}
							}
						</script>
					  <input type="submit" value="删除勾选项" onclick="confirmCheck()"/>
					</form>
					<p>
						<a href="${pageContext.request.contextPath}/type/selectAllTypeMvc.do">添加图书</a>
						<a href="${pageContext.request.contextPath}/type/selectAllByPageMvc.do">查看所有类别</a>
					</p>
					<c:if test="${curPage>1}">
						<a href="${pageContext.request.contextPath}/book/selectAllByPageMvc.do?curPageStr=${curPage-1}">上一页</a>
					</c:if>
					<c:if test="${curPage<total}">
						<a href="${pageContext.request.contextPath}/book/selectAllByPageMvc.do?curPageStr=${curPage+1}">下一页</a>
					</c:if>

				</div>
			</div>
			<div id="footer">
				<div id="footer_bg">
				ABC@126.com
				</div>
			</div>
		</div>
	</body>
</html>
